package com.kvest.sherlocktest;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.kvest.sherlocktest.fragment.Fragment1;

/**
 * Created with IntelliJ IDEA.
 * User: r.belokon
 * Date: 15.04.13
 * Time: 14:42
 * To change this template use File | Settings | File Templates.
 */
public class MyFragmentSherlockActivity extends SherlockFragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.for_fragment);

        getSupportActionBar().setHomeButtonEnabled(true);

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        try {
            fragmentTransaction.add(R.id.fragmnet_store_1, Fragment1.getFragment("First", Color.GREEN, true, "frag1"));
            fragmentTransaction.add(R.id.fragmnet_store_2, Fragment1.getFragment("Second", Color.YELLOW, true, "frag2"));
        } finally {
            fragmentTransaction.commit();
        }
    }

    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            Toast.makeText(this, "This is HOME", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT).show();
        }

        return super.onMenuItemSelected(featureId, item);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getSupportMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
